package com.peng.test.jvm;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * HashMapLoop
 *
 * @author: lupeng6
 * @create: 2021/1/27 19:39
 */
public class HashMapLoop {

    public static void main(String[] args) {
        List<Integer> integers = new LinkedList<>();
        for (int i = 0; i < 1000000; i++) {
            integers.add(new Random().nextInt(1000000));
        }

        Map<Integer, Integer> map = integers.stream().collect(Collectors.toMap(o -> o, Function.identity(), (a, b) -> b));

        System.out.println(map.size());
    }
}
